package AOP;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import Loggers.MyLogger;

@Aspect
@Component
public class MyAspect {

	@Before("execution(* Components.Service.iface.ServiceProxyInterface.*(..))")
	private void advice1() {
		// System.err.println("now transaction begin!");
	}

	@Before("execution(* Components.DAO.common.iface.DBProxyInterface.*(..)) ")
	private void beginTransaction(JoinPoint joinPoint) {
		MyLogger.log(joinPoint.getSignature().toString()
				+ " Database transaction begin!");
	}

	@AfterThrowing("execution(* Components.DAO.common.iface.DBProxyInterface.*(..)) ")
	private void endTransaction(JoinPoint joinPoint) {
		MyLogger.log(joinPoint.getSignature().toString()
				+ " Database transaction end!");
	}

}
